{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_course_manage' %}

{% set script_controller = 'course/manage' %}

{% block main %}
  {% include 'TopxiaAdminBundle:Course:tab.html.twig' %}
  <br>
  <div class="well well-sm mtl">
    <form id="message-search-form" class="form-inline" action="" method="get" novalidate>
      {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}

      <div class="form-group">
        <select style="max-width:150px;" class="form-control" name="categoryId">
          {{ select_options(category_choices('course'), app.request.query.get('categoryId'), '课程分类'|trans) }}
        </select>
      </div>
      <div class="form-group">
        <select class="form-control" name="status">
          {{ select_options(dict('courseStatus'), app.request.query.get('status'), '课程状态'|trans) }}
        </select>
      </div>
      {% if filter == 'normal' %}
        <div class="form-group">
          <select style="max-width:150px;" class="form-control" name="chargeStatus">
            {{ select_options({free:'免费课程'|trans,charge:'收费课程'|trans}, app.request.get('chargeStatus'), '收费状态'|trans) }}
        </select>
        </div>
      {% endif %}

      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{'标题'|trans}}" name="title" value="{{ app.request.get('title') }}">
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{'创建者'|trans}}" name="creator" value="{{ app.request.get('creator') }}">
      </div>
      <button class="btn btn-primary">{{'搜索'|trans}}</button>

      {% include 'TopxiaAdminBundle:Widget:tooltip-widget.html.twig' with { icon: 'glyphicon-question-sign', content: '课程说明Tooltip'|trans|raw, placement: 'left'} %}
    </form>
  </div>
  
  <p class="text-muted">
    <span class="mrl">{{'课程：'|trans}}<strong class="inflow-num">{{ searchCoursesNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'已发布：'|trans}}<strong class="inflow-num">{{ publishedCoursesNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'已关闭：'|trans}}<strong class="outflow-num">{{ closedCoursesNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'未发布：'|trans}}<strong class="outflow-num">{{ unPublishedCoursesNum }}</strong> {{ '个'|trans }}</span>
  </p>

  <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
    <thead>
    <tr>
      <th>{{'编号'|trans}}</th>
      <th width="25%">{{'名称'|trans}}</th>
      <th>{{'价格'|trans}}</th>
      {% include 'OrgBundle:Org/Parts:table-thead-tr.html.twig' %}
      <th width="">{{'连载状态'|trans}}</th>
      {% if filter == 'classroom' %}
        <th>{{'所在'|trans}}{{ setting("classroom.name")|default('班级'|trans) }}</th>
      {% else %}
        <th>{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{ '学员'|trans }}{% endif %}
          数
        </th>

      {% endif %}
      {% if filter == 'course' %}
        <th>{{'收入(元)'|trans}}</th>
      {% elseif filter == 'vip' %}
        <th>{{'会员等级'|trans}}</th>
      {% endif %}
      <th>{{'状态'|trans}}</th>
      <th>{{'创建者'|trans}}</th>
      <th>{{'操作'|trans}}</th>
    </tr>
    </thead>
    <tbody>
    {% for course in courses %}
      {% set user = users[course.userId]|default(null) %}
      {% set category = categories[course.categoryId]|default(null) %}
      {% include 'TopxiaAdminBundle:Course:tr.html.twig' %}
    {% else %}
      <tr>
        <td colspan="20">
          <div class="empty">{{'暂无课程记录'|trans}}</div>
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
  {% include 'OrgBundle:Org:batch-update-org-btn.html.twig' with {module:'course', formId:'course-table'} %}
  {{ admin_macro.paginator(paginator) }}

{% endblock %}